<?php
	//分变量
	function assign($name=null,$value=null){
		static $_var=array();
		//如果$name为null返回静态数组
		if(is_null($name)){
			return $_var;
		}
		$_var[$name]=$value;
	}
	//显示视图
	function display($tpl){
		$content = file_get_contents($tpl);
		//获得分配的所有变量
		$_vars = assign();
		foreach($_vars as $name=>$value){
			// echo $name.'=>'.$value."<br/>";
			$preg = '/\{hd:\$'.$name.'\}/';
			$content = preg_replace($preg, $value,$content);
		}
		echo $content;
	}
?>